﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>! </title>
		<link type="text/css" rel="stylesheet" href="/static/main.css" />
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
		<script type="text/javascript">
			function submit(){
				$.post(
				    "/messageboard",
				    {content: $("#content").val()},  
				    function() {
					    loadmessage(); 
					    $("#content").val("");
				    }  
				);  
			}
			function loadmessage(){
				$.ajax({
					type: "GET",  
					url: "/messageboard",
					data: {useajax: 1},
					dataType: "xml",
					timeout: 5000,
					error: function() {alert("error");},  
					success: function(xml) {
						$("#messagelist").empty();
						$("message", xml).each(function(i){
							var msg = "";
							var message = $("message", xml).get(i)

							msg += $("nickname", message).text();
							msg += ": ";
							msg += "<blockquote><pre>" + $("content", message).text() + "</pre></blockquote>";
							$('#messagelist').prepend(msg);
						});
						//alert("success");
					}
				}); 
			}
			$(document).ready(
				function(){
					$("#submit").click(submit);
					loadmessage();
				}
			)
		</script>
	</head>
	<body>
		<div id="header">
			<div id="login">
			</div>
		</div>
		<div id="container">
			<div>留言列表: </div>
			<div id="messagelist"></div>
			<div>留言: </div>
			<div><textarea id="content" name="content" rows="5" cols="60"></textarea></div>
      		<div><input type="submit" id="submit" value="提交" /></div>
		</div>
		<div id="navi"><a href="/">主页</a><a href="/messageboard">留言板</a></div>
		<script type="text/javascript" src="/static/ga.js"></script>	
	</body>
</html>
